package com.example.web_project_xianyu.mappers;

import com.example.web_project_xianyu.entity.Comment;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface commentMapper {
    @Select("select * from comment_table where product_id = #{product_id}")
    List<Comment> get_product_comment(int product_id);

    @Insert("insert into comment_table(user_id,user_name,product_id, time, comment) values(#{user_id},#{user_name},#{product_id},#{time},#{comment})")
    void add_comment(@Param("user_id")int user_id, @Param("user_name")String user_name, @Param("product_id")int product_id, @Param("time")String time, @Param("comment")String comment);

    @Delete("delete from comment_table where product_id=#{product_id}")
    void delete_product(int product_id);
}
